import { useEffect, useState } from "react";


function EffectList() {
    const [list, setList] = useState([]);
    useEffect(() => {
        async function getList(){
            const res = await fetch("http://geek.itheima.net/v1_0/channels");
            const result = await res.json();
            setList(result.data.channels)
        }  
        getList();
    }, []);
    return (
        <div>
            <h1>useEffect的例子</h1>
            <ul>
                {list.map((item) => (
                    <li key={item.id}>{item.name}</li>
                ))}
            </ul>
        </div>
    )
}

export default EffectList;